﻿<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/struts-dojo-tags" prefix="sx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Manter Matricula</title>
    </head>
    <body>

        <h1>EFETUAR MATRÍCULA - ${operacao}</h1>

        <s:form action="Matricular" onsubmit="return verificaHorarios(this)">

            <s:hidden name="turmaSerial"></s:hidden>

            <s:textfield name="aluno.matricula" label="Matricula" value="%{aluno.matricula}" readonly=""></s:textfield>
            <s:textfield name="aluno.nome" label="Nome" value="%{aluno.nome}" readonly=""></s:textfield>
                <table border>
                    <tr>
                        <td></td><td>Nome da Disciplina</td><td>Horário da Turma (DIA - HORA)</td>
                    </tr>
                <s:iterator value="turmas">
                    <tr>
                        <td>

                            <input type="checkbox" name="chkTurmas" value="${codTurma}"
                                   <s:iterator value="avaliacoes">
                                       <s:if test="%{turma.codTurma==codTurma}">checked</s:if></s:iterator>></input>
                                   </td>
                                   <td>
                            ${disciplina.nome}
                        </td>
                        <td>
                            <s:iterator value="horarios">
                                (${diaSemana} - ${horarioInicio})
                            </s:iterator>
                        </td>
                    </tr>
                </s:iterator>
            </table>
                
            <s:submit action="voltarMatricular" value="Voltar"></s:submit>
            <s:submit action="confirmarMatricular" value="Confimar"></s:submit>

        </s:form>

        <SCRIPT type="text/javascript">
            function verificaHorarios(form) {
                var turmaSerial = "";
                for (i = 0; i < form.chkTurmas.length; i++) {
                    if (form.chkTurmas[i].checked) {
                        turmaSerial += form.chkTurmas[i].value + ",";
                    }
                }
                form.turmaSerial.value = turmaSerial;

                return true;
            }
        </SCRIPT>        
    </body>
</html>
